<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body{
            background:linear-gradient(to right,orange,aqua,yellow);
        }
        #clock{
            border: 10px solid black;
            width: 400px;
            height: 400px;
            background-color: antiquewhite;
            margin: 100px auto;
            position: relative;
            border-radius: 50%;
            --rotation:0;
           
        }
       
        .n1{--rotation:30deg;}
        .n2{--rotation:60deg;}
        .n3{--rotation:90deg;}
        .n4{--rotation:120deg;}
        .n5{--rotation:150deg;}
        .n6{--rotation:180deg;}
        .n7{--rotation:210deg;}
        .n8{--rotation:240deg;}
        .n9{--rotation:270deg;}
        .n10{--rotation:300deg;}
        .n11{--rotation:330deg;}
        .n12{--rotation:360deg;}
        #clock .num{
            width: 100%;
            height: 100%;
            position: absolute;
            left: 0;
            top: 0;
            text-align: center;
            transform: rotate(var(--rotation));
        }
        #clock::after{
            content: "";
            position: absolute;
            left: 50%;
            top: 50%;
            width: 30px;
            height: 30px;
            transform: translate(-50%,-50%);
            background-color: brown;
            border-radius: 50%;
        }
        #clock .hand{
            position: absolute;
            left: 50%;
            top: 50%;
            transform-origin: center top;
            transform: translate(-50%,0);
        }
        #needle_h{
            width: 20px;
            height: 100px;
            background-color: red;
            border-radius: 12px;
        }
        #needle_m{
            width: 10px;
            height: 130px;
            background-color: burlywood;
            border-radius: 8px;
        }
        #needle_s{
            width: 5px;
            height: 180px;
            background-color: azure;
            border-radius: 4px;
        }
    </style>
</head>
<body>
    
    <div id="clock">
        <div id="needle_h" class="hand"></div>
        <div id="needle_m" class="hand"></div>
        <div id="needle_s" class="hand"></div>
        <div class="num n1">1</div>
        <div class="num n2">2</div>
        <div class="num n3">3</div>
        <div class="num n4">4</div>
        <div class="num n5">5</div>
        <div class="num n6">6</div>
        <div class="num n7">7</div>
        <div class="num n8">8</div>
        <div class="num n9">9</div>
        <div class="num n10">10</div>
        <div class="num n11">11</div>
        <div class="num n12">12</div>
    </div>
    <script>
        var clock = document.getElementById("clock");
        var needle_h = document.getElementById("needle_h");
        var needle_m = document.getElementById("needle_m");
        var needle_s = document.getElementById("needle_s");
        adjust()
        setInterval(()=>{
            adjust()
        },1000)
        //获取元素
        //获取时间
        //调整角度
        function gettime(){
            return new Date();
        }
        function date_h(){
            var alltime = gettime();
            var hour = alltime.getHours();
            if(hour>12){
                hour-=12
            }
            return hour;
        }
        function date_m(){
            var alltime = gettime();
            var minute = alltime.getMinutes();
            return minute
        }
        function date_s(){
            var alltime = gettime();
            var second = alltime.getSeconds();
            return second
        }
        //act
        function adjust(){
            var hours = date_h()
            var minutes = date_m()
            var seconds = date_s();
            // console.log(seconds);
            needle_s.style.setProperty("transform",`translate(-50%,0) rotate(${seconds*6+180}deg)`)
            needle_m.style.setProperty("transform",`translate(-50%,0) rotate(${minutes*6+180}deg)`)
            needle_h.style.setProperty("transform",`translate(-50%,0) rotate(${hours*30+(minutes/2)+180}deg)`)


        } 
        

    </script>
</body>
</html>